<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.addEventListener('load', function() {
            // 1.获取房屋名称/面积 所在的文本框元素，给其添加required属性
            document.querySelector('.text1').setAttribute('required', true);

        });
    </script>

</head>

<body>
    <header align="center">
        <h3>创建房屋</h3>
    </header>
    <article align="center">
        <form action="">
            <p>房屋名称：<input type="text" placeholder="请输入名称" class="text1"></p>
            <p>房屋面积：<input type="text" placeholder="请输入名称" class="text2"></p>
            <p>房屋类型: <select name="" id=""><option value="">单间</option><option value="">双间</option></select></p>
            <p>房间数量：<input type="number" min="1" max="5"></p>
            <p>房屋建成时间：<input type="date"></p>
            <p>上传图片：<input type="file" accept="image/gif,image.jpg" multiple="get"></p>
            <p><textarea name="" id="" cols="30" rows="4"></textarea></p>
            <p><button>创建</button></p>
        </form>
    </article>
</body>

</html>